void golomb(int error, int N, FILE * file)
{
  int q,r,bits,cutoff,iter;
  //----------
  // quotient
  //----------
  q=error/N;// integer division
  for(iter=0;iter<q;iter++)
    dec_to_bin_print_bin(1,1,0,file);
  dec_to_bin_print_bin(0,1,0,file);
  //----------
  // remainder
  //----------
  if(N>1)
    // If N==1 then the r==0. This is redundant, and hence
    //does not need to be encoded.
    {
      r=error % N;
      bits = log2_ceil(N);
      cutoff = (1<<bits) - N;
      if(r>=cutoff)
	dec_to_bin_print_bin(r+cutoff,bits,0,file);
      else
	dec_to_bin_print_bin(r,bits-1,0,file);
    }
}


void egk(int error, int m, FILE * file)
{// error should always be less or equal than m
    if (m==error){
        dec_to_bin_print_bin(0,1,0,file);
    }else{
  int q,r,bits,cutoff,iter;
  //----------
  // quotient
  //----------
  dec_to_bin_print_bin(1,1,0,file);
  //----------
  // remainder
  //----------
      r=error;
      bits = log2_ceil(m);
      cutoff = (1<<bits) - m;
      if(r>=cutoff)
	dec_to_bin_print_bin(r+cutoff,bits,0,file);
      else
	dec_to_bin_print_bin(r,bits-1,0,file);
  }//If del principio
}

void plain_code(int pix, FILE * file){
    dec_to_bin_print_bin(pix,8,0,file);
}


